<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  <script src="../js/babel.js"></script>
</head>

<body>
  <div id="root"></div>
</body>

</html>

<script type="text/babel">

  class Weather extends React.Component {
    state = {
      isStatus: false
    }

    changeWeather = () => {
      this.setState({
        isStatus: !this.state.isStatus
      })
    }

    render() {
      return (
        <div onClick={this.changeWeather}>
          <h2>今天天气{this.state.isStatus ? '炎热' : '凉爽'}</h2>
        </div>
      )
    }
  }

  ReactDOM.render(<Weather />, document.getElementById('root'))

</script>